import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;


public class MapMain {

	public static void main(String[] args) {
		Map<String,Integer> map = new HashMap();
		map.put("Lucy", 5);
		map.put("Lily", 4);
		map.put("Han Meimei", 5);
		map.put("Jim", 3);
		map.put("Zou Encen", 3);
		map.put("TangXiaoHu", 3);
		String key = "TangXiaoHu";
		Integer value = null ;
		if (map.containsKey(key))
		{
			value = ( map.get(key));
			System.out.println("Use key:" + key + " find value:" + value);
		}
		else
		{
			System.out.println("Does not contain key:" + key);
		}
		
		key = "Zou Encen";
		if (map.containsKey("Tom"))
		{
			value = map.get(key);
			System.out.println("Use key:" + key + " find value:" + value);
		}
		else
		{
			System.out.println("Does not contain key:" + key);
			value = map.get(key);
			System.out.println("Use key:" + key + " find value:" + value + " If map does not contain key, it will return null, be carefull.");
		}

		key = "Tom";
		if (map.containsKey(key))
		{
			value = map.get(key);
			System.out.println("Use key:" + key + " find value:" + value);
		}
		else
		{
			System.out.println("Does not contain key:" + key);
			value = map.get(key);
			System.out.println("Use key:" + key + " find value:" + value + " If map does not contain key, it will return null, be carefull.");
		}

		Iterator it = map.entrySet().iterator();
		while (it.hasNext()){
			Map.Entry entry = (Map.Entry) it.next();
			key=(String) entry.getKey();
			value= (int) entry.getValue();
			System.out.println("Use iterator to get the first entry is Key :"+key+"  Value :"+value);
		}

        

	}

}
